let Id;
layui.config({
    version:'1510164124181'
}).use(['form', 'laypage', 'layer', 'element'],function(){
    form = layui.form;
    layer = layui.layer;
    $ = layui.jquery;
    laypage = layui.laypage;//分页
    element = layui.element; //元素操作
    Id = GetQueryString("Id");
    if(!isNotNull(Id)){
        Id=0;
    }else{
        selectSysInfoById();
    }
});

function selectSysInfoById() {
    var index = top.layer.msg('加载中，请稍候',{icon: 16,time:false,shade:0.8});
    $.ajax({
        url: httpurl+"/selectSysInfoById",
        cache: false,
        data: {
            "id":Id,
        },
        headers: {
            "Access-Control-Allow-Origin": "*",
            "Access-Control-Allow-Methods": "*",
            "Access-Control-Allow-Headers": "Authorization",
            "Authorization": GetTokenInfo()
        },
        contentType : 'application/json',
        success: function (data) {
            var dataInfo=data.data;
            top.layer.closeAll();
            $("#name").val(dataInfo.name);
            $("#identify").val(dataInfo.identify);
            $("#value").val(dataInfo.value);
            $("#note").val(dataInfo.note);

        }
    });
}

function submitInfo(){
    var name=$("#name").val();
    var identify=$("#identify").val();
    var value=$("#value").val();
    var note=$("#note").val();
    let httpAjax="updateSysInfoById";
    if(Id==0){
        httpAjax="insertSysInfoInfo";
    }
    $.ajax({
        type: "POST",
        url: httpurl + "/"+httpAjax,
        cache: false,
        data: JSON.stringify({
            "id":Id,
            "name":name,
            "identify":identify,
            "value":value,
            "note":note,
            "username":""
        }),
        headers: {
            "Access-Control-Allow-Origin": "*",
            "Access-Control-Allow-Methods": "*",
            "Access-Control-Allow-Headers": "Authorization",
            "Authorization": GetTokenInfo()
        },
        contentType : 'application/json',
        success: function (data) {
            console.log(JSON.stringify(data));
            if(data.rtnCode==200){
                layer.msg("添加成功!!");
                re();
            }
        },error:function (data) {
            layer.msg("读取接口失败,请稍后再试试");
        }
    })
}
function re() {
    window.location.href="SysInfo.html";
}
